{% extends 'index.html' %}
{% load stu_tags %}
{% block page-content %}
    <div class="panel panel-default">
    <div class="panel-heading">班级：{{ studyrecord_obj.student.enrolled_class }} |
        节次：{{ studyrecord_obj.course_record.day_num }}</div>
    <div class="panel-body">
        <h4>作业标题: {{ studyrecord_obj.course_record.homework_title }}</h4>
        <hr>
        <h4>作业详情:
            <pre>{{ studyrecord_obj.course_record.homework_content }}</pre>
        </h4>
        <h4>老师评语:
            <pre>{{ studyrecord_obj.memo }}</pre>
        </h4>
        <h4>本节成绩: {{ studyrecord_obj.score }}</h4>
        <form id="filedropzone" method="post" action="{{ request.path }}" class="dropzone dz-clickable"
              onsubmit="return RegisterFormCheck()">{% csrf_token %}
            <div class="dz-default dz-message">
                <div class="dz-icon icon-wrap icon-circle icon-wrap-md">
                    <i class="fa fa-cloud-upload fa-3x"></i>
                </div>
                <div>
                    <p class="dz-text">把要提交的文件拖到这里</p>
                    <p class="text-muted">上传前请将代码打包成.zip格式</p>
                </div>
            </div>
        </form>
    </div>
{% endblock %}

{% block buttom-js %}
    <script>
        function RegisterFormCheck() {

            if (myDropzone.files.length < 1) {
                alert("请添加文件!");
                return false
            }


        }

        $(document).ready(function () {
            Dropzone.options.filedropzone = {
                url: "{{ request.path }}",
                paramName: "file", // The name that will be used to transfer the file
                maxFilesize: 3, // MB,
                addRemoveLinks: true,
                maxFiles: 2,
                uploadMultiple: true,
                accept: function (file, done) {
                    if (! file.name.endsWith(".zip")) {
                        alert("只能上传zip格式的压缩包")
                    }
                    else {
                        done();
                    }
                }
            };


            Dropzone.autoDiscover = false;
            myDropzone = new Dropzone("#filedropzone");
            myDropzone.on("addedfile", function (file) {
                console.log("---------", file)
            });
        });
    </script>
{% endblock %}